From 09ed3d9bce75243f6f8db807ed3c73441c9333bb Mon Sep 17 00:00:00 2001 From: Philipp Sadleder Date: Mon, 12 Jul 2010 16:49:12 +0200 Subject: [PATCH] Add experimental introspection support. Disabled by default; use --enable-introspection to enable it. --- ChangeLog.pre-0-1 | 1 - Makefile.am | 5 ++- autogen.sh | 4 +- babl/Makefile.am | 38 ++++++++++++++++++ configure.ac | 3 ++ m4/introspection.m4 | 94 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 141 insertions(+), 4 deletions(-) create mode 100644 m4/introspection.m4 diff --git a/ChangeLog.pre-0-1 b/ChangeLog.pre-0-1 index 14711c1..a81c443 100644 --- a/ChangeLog.pre-0-1 +++ b/ChangeLog.pre-0-1 @@ -1,4 +1,3 @@ - =========================== 0.1.0 released ============================= 2009-05-20 Martin Nordholts diff --git a/Makefile.am b/Makefile.am index 8e95d7a..23b9f8a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,5 @@ +ACLOCAL_AMFLAGS = -I m4 +DISTCHECK_CONFIGURE_FLAGS = --enable-introspection AUTOMAKE_OPTIONS = foreign dist-bzip2 SUBDIRS = \ @@ -21,7 +23,8 @@ EXTRA_DIST = \ TODO \ ChangeLog \ autogen.sh \ - babl.pc.in + babl.pc.in \ + m4/introspection.m4 DISTCLEANFILES = \ $(built_dist_files) \ diff --git a/autogen.sh b/autogen.sh index a149e4e..cd9712b 100755 --- a/autogen.sh +++ b/autogen.sh @@ -9,10 +9,10 @@ # tools and you shouldn't use this script. Just call ./configure # directly. -ACLOCAL=${ACLOCAL-aclocal-1.9} +ACLOCAL=${ACLOCAL-aclocal} AUTOCONF=${AUTOCONF-autoconf} AUTOHEADER=${AUTOHEADER-autoheader} -AUTOMAKE=${AUTOMAKE-automake-1.9} +AUTOMAKE=${AUTOMAKE-automake} LIBTOOLIZE=${LIBTOOLIZE-libtoolize} AUTOCONF_REQUIRED_VERSION=2.54 diff --git a/babl/Makefile.am b/babl/Makefile.am index 12cd969..3f061fa 100644 --- a/babl/Makefile.am +++ b/babl/Makefile.am @@ -81,3 +81,41 @@ libbabl_@BABL_API_VERSION@_la_LIBADD=\ libbabl_@BABL_API_VERSION@_la_LDFLAGS= \ ${no_undefined} $(MATH_LIB) \ -version-info $(BABL_LIBRARY_VERSION) + +# GObject Introspection +-include $(INTROSPECTION_MAKEFILE) +INTROSPECTION_GIRS = +INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) +INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) + +if HAVE_INTROSPECTION +Babl-$(BABL_API_VERSION).gir: $(G_IR_SCANNER) + $(INTROSPECTION_SCANNER) -v --namespace Babl --nsversion=$(BABL_API_VERSION) \ + --add-include-path=$(srcdir) --add-include-path=. \ + --library=babl-$(BABL_API_VERSION) \ + --libtool="$(LIBTOOL)" \ + --output $@ \ + --pkg babl \ + -I$(top_srcdir) \ + -I$(top_builddir) \ + $(library_include_HEADERS) \ + $(c_sources) + +girdir = $(INTROSPECTION_TYPELIBDIR) +gir_DATA = Babl-$(BABL_API_VERSION).gir + +typelibsdir = $(INTROSPECTION_TYPELIBDIR) +typelibs_DATA = Babl-$(BABL_API_VERSION).typelib + +EXTRA_DIST = $(gir_DATA) +CLEANFILES = $(gir_DATA) $(typelibs_DATA) + +%.typelib: %.gir + LD_LIBRARY_PATH=$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}. $(INTROSPECTION_COMPILER) \ + --includedir=$(srcdir) \ + --includedir=$(top_builddir)/babl \ + $(G_IR_COMPILER_OPTS) \ + $< -o $@ + + +endif # HAVE_INTROSPECTION diff --git a/configure.ac b/configure.ac index 970896f..0a46daa 100644 --- a/configure.ac +++ b/configure.ac @@ -37,6 +37,7 @@ m4_define([babl_stable], AC_INIT(babl, babl_major_version.babl_minor_version.babl_micro_version) AC_CONFIG_SRCDIR(babl/babl.h) +AC_CONFIG_MACRO_DIR([m4]) # Enable silent build rules by default, requires at least # Automake-1.11. Disable by either passing --disable-silent-rules to @@ -63,6 +64,8 @@ AC_SUBST(BABL_API_VERSION) BABL_RELEASE=babl_api_version AC_SUBST(BABL_RELEASE) +# GObject Introspection +GOBJECT_INTROSPECTION_CHECK([0.6.8]) dnl The symbol BABL_UNSTABLE is defined above for substitution in dnl Makefiles and conditionally defined here as a preprocessor symbol diff --git a/m4/introspection.m4 b/m4/introspection.m4 new file mode 100644 index 0000000..589721c --- /dev/null +++ b/m4/introspection.m4 @@ -0,0 +1,94 @@ +dnl -*- mode: autoconf -*- +dnl Copyright 2009 Johan Dahlin +dnl +dnl This file is free software; the author(s) gives unlimited +dnl permission to copy and/or distribute it, with or without +dnl modifications, as long as this notice is preserved. +dnl + +# serial 1 + +m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL], +[ + AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first + AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first + AC_BEFORE([LT_INIT],[$0])dnl setup libtool first + + dnl enable/disable introspection + m4_if([$2], [require], + [dnl + enable_introspection=yes + ],[dnl + AC_ARG_ENABLE(introspection, + AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]], + [Enable introspection for this build]),, + [enable_introspection=auto]) + ])dnl + + AC_MSG_CHECKING([for gobject-introspection]) + + dnl presence/version checking + AS_CASE([$enable_introspection], + [no], [dnl + found_introspection="no (disabled, use --enable-introspection to enable)" + ],dnl + [yes],[dnl + PKG_CHECK_EXISTS([gobject-introspection-1.0],, + AC_MSG_ERROR([gobject-introspection-1.0 is not installed])) + PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], + found_introspection=yes, + AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME])) + ],dnl + [auto],[dnl + PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no) + ],dnl + [dnl + AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@]) + ])dnl + + AC_MSG_RESULT([$found_introspection]) + + INTROSPECTION_SCANNER= + INTROSPECTION_COMPILER= + INTROSPECTION_GENERATE= + INTROSPECTION_GIRDIR= + INTROSPECTION_TYPELIBDIR= + if test "x$found_introspection" = "xyes"; then + INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0` + INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0` + INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0` + INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0` + INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)" + INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0` + INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0` + INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection + fi + AC_SUBST(INTROSPECTION_SCANNER) + AC_SUBST(INTROSPECTION_COMPILER) + AC_SUBST(INTROSPECTION_GENERATE) + AC_SUBST(INTROSPECTION_GIRDIR) + AC_SUBST(INTROSPECTION_TYPELIBDIR) + AC_SUBST(INTROSPECTION_CFLAGS) + AC_SUBST(INTROSPECTION_LIBS) + AC_SUBST(INTROSPECTION_MAKEFILE) + + AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes") +]) + + +dnl Usage: +dnl GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version]) + +AC_DEFUN([GOBJECT_INTROSPECTION_CHECK], +[ + _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1]) +]) + +dnl Usage: +dnl GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version]) + + +AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE], +[ + _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require]) +]) -- 2.30.2